﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;


namespace TestFramework
{
    public class PageLogin:Page
    {
        private TextBox userName;
        private TextBox passWord;
        private WebButton loginButton;

        public PageLogin(IWebDriver driver, string url)
            : base(driver, url)
        {
            userName = new TextBox(driver, By.Id("login_UserName"));
            passWord = new TextBox(driver, By.Id("login_Password"));
            loginButton = new WebButton(driver, By.Id("login_LoginButton"));
        }

        public void LogIn(string name, string pass)
        {
              this.NavigateUrl();
                if (userName.WaitForElement())
                {
                    userName.InputText(name);
                    passWord.InputText(pass);
                    loginButton.Click();

                }
        }
    }


    public class PageLogOut : Page
    {
        public PageLogOut(IWebDriver driver, string url)
            : base(driver, url)
        { 

        }

        public void LogOut()
        {
            this.NavigateUrl();
        }
    }

    public class PageTopupTelcel : Page
    {
        private DropdownList providerList;
        private DropdownList amountList;
        private TextBox mobiletext;
        private TextBox confirmMobiletext;
        private WebButton okButton;
        private WebButton cancelButton;
        private WebButton popupButton;

        public PageTopupTelcel(IWebDriver driver, string url)
            : base(driver, url)
        {
            providerList = new DropdownList(driver, By.XPath("//select[contains(@id,'providerDropDownList')]"));
            amountList = new DropdownList(driver, By.Name("ctl00$pageContentContentPlaceHolder$amountDropDownList"));
            mobiletext = new TextBox(driver, By.XPath("//input[@id='pageContentContentPlaceHolder_mobileNumberTextBox']"));
            confirmMobiletext = new TextBox(driver, By.XPath("//input[@id='pageContentContentPlaceHolder_confirmMobileNumberTextBox']"));
            okButton = new WebButton(driver,By.XPath("//input[@id='pageContentContentPlaceHolder_rechargeButton']"));
            cancelButton = new WebButton(driver, By.XPath("//input[@id='pageContentContentPlaceHolder_cancelButton']"));
            popupButton = new WebButton(driver, By.Id("popupButton"));
            
        }

        public void TopupTelcel(string provider,string mobile,string confirmmobile,string amount)
        {
            providerList.WaitForElement();
            providerList.SelectByValue(provider);
            mobiletext.InputText(mobile);
            confirmMobiletext.InputText(confirmmobile);
            this.amountList.SelectByValue(amount);
            okButton.Click();
            //popupButton.WaitForElement();
            //popupButton.Click();
            
            mdriver.FindElement(By.Id("popupButton")).Click();
            mdriver.FindElement(By.CssSelector("div.SelectedSubItem"));
                
        }

        public void TopupTelcelCancel(string provider, string mobile, string confirmmobile, string amount)
        {
            providerList.SelectByValue(provider);
            mobiletext.InputText(mobile);
            confirmMobiletext.InputText(confirmmobile);
            this.amountList.SelectByValue(amount);
            cancelButton.Click();
            
        }


    }
}
